/* eslint-disable */
import { constants } from './constants.js'

export const core = {
  token: function(value) {
    let storage = window.localStorage,
      key = constants.STORAGE_TOKEN_KEY;

    if (arguments.length >= 1) {
      if (it.nil(value)) {
        storage.removeItem(key);
      } else {
        storage.setItem(key, value);
      }
    } else {
      return storage.getItem(key) || undefined;
    }
  }
}

export function nil(value) {
  return !exist(value);
}

export function exist(value) {
  return value !== null && value !== undefined;
}
